<ap></ap>{include file="common/head"/}
<div class="admin-main layui-anim layui-anim-upbit">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>点评{:lang('list')}</legend>
    </fieldset>
    <div class="demoTable">
        <div class="layui-inline">
            <label class="layui-form-label">服务评价:</label>
            <div class="layui-input-inline">
                <select name="yid" id="fid" lay-verify="required" lay-search="" class="layui-select">
                    <option value="">选择评价</option>
                    {foreach name="fwlist" item="v" key="k"}
                    <option value="{$v['id']}">{$v['title']}</option>
                    {/foreach}
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">菜品评价:</label>
            <div class="layui-input-inline">
                <select name="tid" id="cid" lay-verify="required" lay-search="" class="layui-select">
                    <option value="">选择评价</option>
                    {foreach name="cplist" item="v" key="k"}
                    <option value="{$v['id']}">{$v['title']}</option>
                    {/foreach}
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">评论时间</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" id="start" placeholder="yyyy-MM-dd">
            </div>
        </div>到
        <div class="layui-inline">
            <div class="layui-input-inline">
                <input type="text" class="layui-input" id="end" placeholder="yyyy-MM-dd">
            </div>
        </div>
        <button class="layui-btn" id="search" data-type="reload">搜索</button>
    </div>
    <table class="layui-table" id="list" lay-filter="list" style="width: 1200px;"></table>
</div>

{include file="common/foot"/}

<script>
    layui.use(['table','form'], function() {
        var table = layui.table,form = layui.form,$ = layui.jquery;
        var tableIn = table.render({
            elem: '#list',
            url: '{:url("staffList")}',
            method:'post',
			toolbar: '#topBtn',
			title:'{:lang("admin")}{:lang("list")}',
            cols: [[
                {field:'id', title: '编号', width:60,fixed: true}
                ,{field:'table', title: '桌号', width:80}
				,{field:'yid', title: '服务员编号', width:100}
                ,{field:'fwpj', title: '服务评价', width:100}
                ,{field:'ftag', title: '服务标签', width:220}
                ,{field:'fdesc', title: '服务备注', width:300, edit: 'text'}
                ,{field:'cppj', title: '菜品评价', width:100}
                ,{field:'ctag', title: '菜品标签', width:250}
                ,{field:'cdesc', title: '菜品备注', width:300, edit: 'text'}
                ,{field:'day', title: '时间', width:200}
            ]]
        });
        //监听单元格编辑
        table.on('edit(list)', function(obj){
            var value = obj.value //得到修改后的值
                ,data = obj.data //得到所在行所有键值
                ,field = obj.field; //得到字段
            $.post('{:url("staffEdit")}',{id:data.id,field:field,des:value},function (res) {
                if (res){
                    layer.msg('修改成功!');
                }else {
                    layer.msg('修改失败!');
                }
            });

        });

        //搜索
        $('#search').on('click', function() {
            var fid = $('#fid').val();
            var cid = $('#cid').val();
            var start = $("#start").val();
            var end = $("#end").val();
            if(fid==='' && cid ==='') {
                layer.msg('{:lang("pleaseEnter")}搜索条件！',{icon:0});
                return;
            }
            tableIn.reload({ page: {page: 1},where: {fid: fid,cid:cid,start:start,end:end}});
        });

    });
</script>
<script>
    layui.use('laydate', function(){
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
        });
    });
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        //执行一个laydate实例
        laydate.render({
            elem: '#end' //指定元素
        });
    });
</script>
</body>
</html>